package com.doudou.provider.controller;

import com.doudou.client.BasicClient;
import com.doudou.client.client.BackendClient;
import com.doudou.client.client.TestClient;
import com.doudou.commons.entity.Result;
import com.doudou.provider.SecurityContextUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;

/**
 * @Author: 傻男人
 * @Date: 2020/5/26 14:41
 * @Version: 1.0
 * @Description:
 */
@RestController
@Slf4j
public class TestController {

    @Autowired
    private TestClient testClient;

    @Autowired
    private BackendClient backendClient;

    @Autowired
    private BasicClient basicClient;

    @GetMapping("/testCon")
    public Result getOrder(@RequestParam("name")String name, Principal principal){
        System.out.println(SecurityContextUtils.getLoginAccount());
        System.out.println(SecurityContextUtils.getAuthenticationInfo());
        return testClient.testCon(name);
    }

    @GetMapping("/manager")
    public String backendTest(@RequestParam("name") String name){
        return backendClient.backendTest(name);
    }

    @GetMapping("/basic")
    public Result getOrder(){
        return basicClient.findByClientId("client_1");
    }

}
